Skip to content

Conversation

marcabreracast
Copy link
Collaborator

@marcabreracast marcabreracast commented Jul 9, 2025

Description

  • Adds azure to cloud-provider config in federated_database_instance
  • Refactored out the cloud_provider_access setup for Azure to acc.cloud_provider_access.go
  • There is already a migration test for empty CloudProvider config, so decided not to include an extra migration test.

Link to any related issue(s): CLOUDP-245406

Follow up Work

  1. Implement data source and refactor tests to run together with resource.
  2. Add documentation

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Type: schema.TypeList,
MaxItems: 1,
Required: true,
Optional: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Investigation notes:

  1. cloud_provider_config (parent attribute) is not required in the create operation and is not returned from the API when it is not set. However, the attribute is already marked as Optional+Computed, so keeping it as is to allow no-op when the attribute is removed.
  2. aws changing from required to optional to allow azure usage

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This information: Changing from required to optional to allow azure usage I would keep only as a PR comment.
Later after this is merged it will be no surprise to find this as optional.

Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add:

          AZURE_ATLAS_APP_ID: ${{ inputs.azure_atlas_app_id }}
          AZURE_SERVICE_PRINCIPAL_ID: ${{ inputs.azure_service_principal_id }}
          AZURE_TENANT_ID: ${{ inputs.azure_tenant_id }}

Here: MONGODB_ATLAS_FEDERATION_SETTINGS_ID: ${{ inputs.mongodb_atlas_federation_settings_id }} so the test can use Azure in CI

Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need to update the schema of the data sources too. Due to this failing tests:
https://github.com/mongodb/terraform-provider-mongodbatlas/actions/runs/16174869633/job/45657910272#step:5:91

github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).Set(0xc001192750, {0x2d7628f, 0x15}, {0x2619600, 0xc001a8eff0})
	/home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource_data.go:238 +0x2b2
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/federateddatabaseinstance.dataSourceMongoDBAtlasFederatedDatabaseInstanceRead({0x3197340, 0xc00057e150}, 0xc001192750, {0x2864b80?, 0xc001b6d740?})
	/home/runner/work/terraform-provider-mongodbatlas/terraform-provider-mongodbatlas/internal/service/federateddatabaseinstance/data_source_federated_database_instance.go:336 +0x78d

Copy link
Contributor

This PR has gone 7 days without any activity and meets the project’s definition of "stale". This will be auto-closed if there is no new activity over the next 7 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!

@github-actions github-actions bot added the stale label Jul 17, 2025
@marcabreracast
Copy link
Collaborator Author

Test failing due to config issue, which is also happening on nightly run tests.

@marcabreracast marcabreracast added not_stale Not stale issue or PR and removed stale labels Jul 18, 2025
@marcabreracast marcabreracast marked this pull request as ready for review July 18, 2025 10:03
@marcabreracast marcabreracast requested review from a team as code owners July 18, 2025 10:03
Copy link
Contributor

APIx bot: a message has been sent to Docs Slack channel

cloudProviderDataSource = `
data "mongodbatlas_cloud_provider_access_setup" "test" {
project_id = mongodbatlas_cloud_provider_access_setup.test.project_id
provider_name = "AWS"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AWS provider name for the Azure config?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@ytineo-mongodb ytineo-mongodb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines +65 to +67
Required: required,
Computed: computed,
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Required: required,
Computed: computed,
},
Required: !isDataSource,
Computed: isDataSource,
},

nit: Having the required/computed variables adds one additional level of indirection, might be easier to follow if the criteria is explicit in the schema directly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the concern about the level of indirection, however I believe for readability purposes it's better to keep the variables as they are, since it won't require a mental mapping of the boolean logic.

var maxItems int
if isDataSource {
computed = true
maxItems = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why we would set max items to 0?
If we go for modifying the data source schema of existing attributes Ideally aws would simply be Computed-only attribute. Since we have this inconsistent schema in the data source as for the scope of this PR would leave it as is, similar to test_s3_bucket.
If done as part of this ticket we have to ensure it has no impact and I would go for setting as compute-only over modifying the max items.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, setting MaxItems = 0 is basically the same as leaving it unset. Since this function is used for both resource and data source schemas, setting it to 0 won't have any impact. Only for the resource, where it's set to 1.

Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! LGTM.

Copy link
Collaborator

@oarbusi oarbusi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marcabreracast marcabreracast merged commit be53c0a into master Jul 21, 2025
40 of 41 checks passed
@marcabreracast marcabreracast deleted the CLOUDP-245406_DataFederation_AddAzureSupportForCloudProviderConfig branch July 21, 2025 13:49
svc-apix-Bot added a commit that referenced this pull request Jul 21, 2025
lantoli added a commit that referenced this pull request Jul 23, 2025
…_peering

* CLOUDP-320243-dev-2.0.0:
  fix: Changes `actions` attribute to TypeSet in `mongodbatlas_custom_db_role` to not be sensitive to order (#3508)
  chore: Updates CHANGELOG.md for #3513
  fix: Sets org_id on import of `mongodbatlas_organization` resource (#3513)
  go 1.24.5 (#3514)
  chore: Updates CHANGELOG.md for #3484
  feat: Add azure attributes in federated database instance resource (#3484)
  chore: Updates CHANGELOG.md for #3505
  feat: Add support for `MONGODB_ATLAS_PUBLIC_API_KEY` and `MONGODB_ATLAS_PRIVATE_API_KEY` to TF (#3505)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement not_stale Not stale issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants